﻿using System;
using PMngr.Data;

namespace PMngr.Main
{
    public partial class AddOption : BaseControl
    {
        public event EventHandler InitializeHandler = delegate { };
        public event EventHandler UpdateHandler = delegate { };
        public event EventHandler DeleteHandler = delegate { };

        public AddOption()
        {
            InitializeComponent();           
        }

        public new string Name 
        {
            get
            {
                return txtName.Text;
            }
            set
            {
                txtName.Text = value;
            }
        }

        public string Desc
        {
            get
            {
                return txtDesc.Text;
            }
            set
            {
                txtDesc.Text = value;
            }
        }

        public int Order
        {
            get
            {
                return (int)nudOrder.Value;
            }
            set
            {
                nudOrder.Value = value;
            }
        }
        public bool IsValid 
        {
            get
            {
                return chkValid.Checked;
            }
            set
            {
                chkValid.Checked = value;
            }
        }

        private void BtnSaveClick(object sender, EventArgs e)
        {
            UpdateHandler(sender, e);
        }

        private void AddOptionLoad(object sender, EventArgs e)
        {
            InitializeHandler(sender, e);
        }
    }

    public class OptionEventArgs : EventArgs
    {
        public OptionEventArgs(ItemBase option)
        {
            Option = option;
        }

        public ItemBase Option { get; private set; }
    }
}
